package com.android.volley.http;

import java.io.IOException;
import java.io.OutputStream;
import java.util.Objects;

public class BinaryBody implements ContentBody{
    private final byte[] mContent;
    private final String mFileName;

    public BinaryBody(String fileName, byte[] content) {
        this.mFileName = Objects.requireNonNull(fileName);
        this.mContent = Objects.requireNonNull(content);
    }

    @Override
    public void writwTo(OutputStream out) throws IOException {
        out.write(mContent);
    }

    @Override
    public String getContentType() {
        return TYPE_OCTET_STREAM;
    }

    @Override
    public String getContentTransferEncoding() {
        return BINARY_ENCODING;
    }

    @Override
    public String getFileName() {
        return mFileName;
    }
}
